package com.androidx.p013lv.invention.fragment;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.androidx.p013lv.base.bean.TopTabBean;
import com.androidx.p013lv.base.bean.TwoBean;
import com.androidx.p013lv.base.bean.VideoBean;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.NetUtil;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.invention.C1069R;
import com.androidx.p013lv.invention.adapter.AdapterTop;
import com.androidx.p013lv.invention.databinding.FragmentTopBinding;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

/* renamed from: com.androidx.lv.invention.fragment.TopFragment */
public class TopFragment extends LazyFragment<FragmentTopBinding> implements OnRefreshListener {
    String HTTP_TAG = "queryBoardRecord";
    AdapterTop adapter;
    TopTabBean topTabBean;

    public static TopFragment newInstance(TopTabBean topTabBean2) {
        Bundle bundle = new Bundle();
        bundle.putSerializable("data", topTabBean2);
        TopFragment topFragment = new TopFragment();
        topFragment.setArguments(bundle);
        return topFragment;
    }

    @Override // androidx.fragment.app.Fragment
    public void setArguments(Bundle bundle) {
        super.setArguments(bundle);
        this.topTabBean = (TopTabBean) bundle.getSerializable("data");
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public int setFragmentView() {
        return C1069R.C1074layout.fragment_top;
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public void initViews() {
        ViewGroup.LayoutParams layoutParams = ((FragmentTopBinding) this.binding).ivHead.getLayoutParams();
        layoutParams.height = (UiUtils.getWindowWidth() * 214) / 420;
        ((FragmentTopBinding) this.binding).ivHead.setLayoutParams(layoutParams);
        GlideUtils.loadPic(this, SpUtils.getInstance().getString("domain") + this.topTabBean.getSelfImg(), ((FragmentTopBinding) this.binding).ivHead);
        ((FragmentTopBinding) this.binding).refresh.setOnRefreshListener(this);
        ((FragmentTopBinding) this.binding).refresh.setEnableLoadMore(false);
        ((FragmentTopBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(getContext()));
        this.adapter = new AdapterTop(this);
        ((FragmentTopBinding) this.binding).recycler.setAdapter(this.adapter);
        this.adapter.setItemListener(new ItemClickListener() {
            /* class com.androidx.p013lv.invention.fragment.TopFragment.C11491 */

            @Override // com.androidx.p013lv.base.listener.ItemClickListener
            public void onItemClick(View view, int i) {
                TopFragment topFragment = TopFragment.this;
                topFragment.startVideoPlay(((VideoBean) topFragment.adapter.getDataInPosition(i)).getVideoId());
            }
        });
        ((FragmentTopBinding) this.binding).statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.invention.fragment.TopFragment.View$OnClickListenerC11502 */

            public void onClick(View view) {
                TopFragment.this.getInfo();
            }
        });
        getInfo();
    }

    /* access modifiers changed from: package-private */
    public void getInfo() {
        AdapterTop adapterTop = this.adapter;
        if (!(adapterTop == null || adapterTop.getData() == null || this.adapter.getData().size() <= 0)) {
            this.adapter.clear();
        }
        if (!NetUtil.isNetworkAvailable()) {
            ((FragmentTopBinding) this.binding).statusLayout.showNoNet();
            return;
        }
        ((FragmentTopBinding) this.binding).statusLayout.showLoading();
        String queryBoardRecord = UrlManager.getInsatance().queryBoardRecord(this.topTabBean.getType());
        HttpUtils insatance = HttpUtils.getInsatance();
        insatance.get(queryBoardRecord, new HttpCallback<BaseRes<TwoBean>>(this.HTTP_TAG + this.topTabBean.getType()) {
            /* class com.androidx.p013lv.invention.fragment.TopFragment.C11513 */

            public void onLvSuccess(BaseRes<TwoBean> baseRes) {
                TopFragment topFragment;
                if (TopFragment.this.binding != null && ((FragmentTopBinding) TopFragment.this.binding).statusLayout != null && (topFragment = TopFragment.this) != null) {
                    ((FragmentTopBinding) topFragment.binding).statusLayout.hideLoading();
                    ((FragmentTopBinding) TopFragment.this.binding).refresh.finishRefresh();
                    ((FragmentTopBinding) TopFragment.this.binding).refresh.finishLoadMore();
                    if (baseRes.getCode() != 200) {
                        ((FragmentTopBinding) TopFragment.this.binding).statusLayout.showError();
                    } else if (baseRes.getData() == null || baseRes.getData().getList() == null || baseRes.getData().getList().size() <= 0) {
                        ((FragmentTopBinding) TopFragment.this.binding).statusLayout.showEmpty();
                    } else {
                        TopFragment.this.adapter.setDomain(baseRes.getData().getDomain());
                        TopFragment.this.adapter.setData(baseRes.getData().getList());
                    }
                }
            }
        });
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnRefreshListener
    public void onRefresh(RefreshLayout refreshLayout) {
        getInfo();
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onDestroy() {
        super.onDestroy();
        HttpUtils insatance = HttpUtils.getInsatance();
        insatance.cancelTag(this.HTTP_TAG + this.topTabBean.getType());
    }
}
